<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath %>">
<%@include file="/views/global/ShopInclude.jsp" %>
<link href="static/css/module/cart.css" rel="stylesheet" type="text/css">
<title>ORDER CONFIRM</title>
</head>
<body>
<div class="form-container center font">  <!-- 表单填写部分 -->
    <form id="submitForm" name="submitForm" action="buyer/order/create" method="post">
      <div class="cart-title">
      	结算商品
      </div>
      <div class="cartTable font">
      	<div class="form-group row cart-table-head">
	    	<div class="col-xs-1">
	    		<input name="cartSelectAll" type="checkbox" class="checkbox selectAll" checked="checked"/>
	    	</div>
	    	<div class="col-xs-1">
	    		全选
	    	</div>
	    	<div class="col-xs-5">
	    		商品信息
	    	</div>
	    	<div class="col-xs-1">
	    		套餐
	    	</div>
	    	<div class="col-xs-1">
	    		单 价
	    	</div>
	    	<div class="col-xs-2">
	    		数 量
	    	</div>
	    	<div class="col-xs-1">
	    		小 计
	    	</div>
	    </div>
	    <c:if test="${empty cartItems }">
	    	<div class="form-group row">
	    		<div class="alert alert-danger">PLEASE SELECT ITEMS FIRST!</div>
	    	</div>
	    </c:if>
	    <c:forEach var="item" items="${cartItems }">
	    <div class="form-group row">
	    	<div class="col-xs-1">
	    		<input name="itemSelect" type="checkbox" class="checkbox" checked="checked"
	    		 itemId="${item.itemId }" skuId="${item.skuId }" title="${item.title }" propKey="${item.properties }"/>
	    	</div>
	    	<div class="col-xs-1">
	    		<span class="cartItemImg">
	    			<a href="item/detail?id=${item.itemId }" target="_blank"><img width="100" height="100" src="${item.displayFileId }"/></a>
	    		</span>
	    	</div>
	    	<div class="col-xs-5" style="text-align:left;">
	    		<div class="item-info">${item.title }<br/>${item.cnName }</div>
	    	</div>
	    	<div class="col-xs-1">
	    		${item.properties}
	    	</div>
	    	<div class="col-xs-1">
	    		<span class="price">${item.price}</span>
	    	</div>
	    	<div class="col-xs-2">
	    		<ul class="quantitySlipper">
	              <li class="quantityMinus" changeCart="false">-</li>
	              <li class="quantityInput">${item.quantity}</li>
	              <li class="quantityPlus" changeCart="false">+</li>
	            </ul>
	    	</div>
	    	<div class="col-xs-1">
	    		${item.price * item.quantity}
	    	</div>
	    </div>
	    </c:forEach>
	    <div class="form-group row cart-table-end">
	    	<div class="col-xs-7">
	    		<div class="pull-right">
	    			${addressVo.countryName },&nbsp;${addressVo.stateName },&nbsp;${addressVo.cityName },&nbsp;
	    			${addressVo.district } &nbsp;&nbsp;${addressVo.street }
	    		</div>
	    		<textarea rows="4" cols="50" name="strAddressVo" class="hide">${strAddressVo }</textarea>
	    	</div>
	    	<div class="col-xs-5">
	    		<div class="row">
	    			<div class="col-xs-8">
	    				${addressVo.userName }(${addressVo.mobilePhone })
	    			</div>
	    			<div class="col-xs-2">
	    				
	    			</div>
	    			<div class="col-xs-2">
	    				运费 0 元
	    			</div>
	    		</div>
	    	</div>
	    </div>
	    <!-- <div id="msg"></div> -->
	    <c:if test="${not empty cartItems }">
	    <div class="form-group row cart-table-foot">
	    	<div class="pull-right">
    			已选商品 ${fn:length(cartItems) }件, &nbsp;合计 <span class="cartTotalPrice">¥ <span id="totalPrice">${totalPrice }</span></span>
    			&nbsp;&nbsp;
    			<button id="btnBalanceSubmit" type="button" class="btn btn-success btn-lg">结 算</button>
    		</div>
	    </div>
	    </c:if>
      </div>
    </form>
  </div>
  <!-- 提示框 -->
<div class="warningdialog" style="position: fixed;left: 17%;top: 10%;">
  <p>WARNING 提醒<a href="javascript:void(0)" onclick="$('.warningdialog').hide();"></a></p>
  <div class="warningdialogcontent">
      <span id="msg">支付功能将在第二期开放。</span><br>
      <input type="button" value="确定 YES" onclick="$('.warningdialog').hide();">
  </div>
</div>
<!-- 提示框    结束-->
</body>
<%@include file="/views/global/AdminScripts.jsp" %>
<script type="text/javascript" src="static/javascript/module/CartCommon.js"></script>
<script type="text/javascript" src="static/javascript/page/cart.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#btnBalanceSubmit").click(function(){
		var itemArray = new Array();
		$("INPUT[name='itemSelect']:checked").each(function(i, itemObj){
			var item = {
				mealId: 0,
				itemId: $(itemObj).attr("itemId"),
				itemTitle: $(itemObj).attr("title"),
				skuId: $(itemObj).attr("skuId"),
				propKey: $(itemObj).attr("propKey"),
				propName: "",
				amount: $(itemObj).parent().parent().find(".quantityInput").html()
			};
			itemArray.push(item);
		});
		if(0 == itemArray.length){
			$.error("PLEASE SELECT AT LEAST ONE ITEM FIRST!");
			return false;
		}
		$("#submitForm").goAjax({semantic: false, checkLogin: true,
			url: "trade/order/create",
			data:{orderItems: JSON.stringify(itemArray)},
			success: function(jsonData) {
				if(true == jsonData.success){
					$("#msg").text("保存成功！");
					$(".warningdialog").show();					
	   				//$("#msg").alert({type:'alert-success', text: '保存成功！'});
	   			} else {
	   				$("#msg").text("保存失败:" + jsonData.message);
					$(".warningdialog").show();
	   				//$("#msg").alert({type:'alert-danger', text: '保存失败: ' + jsonData.message});
	   			}
				
			}
		});
	})
});
</script>
</html>
